Helpful Information
 
 
Category: vB
VB -> C++

I used to know Visual Basic, and I've been learning C++

In Visual Basic, I was able to use a 'PropertyBag' which held data that you wrote through WriteProperty, and read itthrough ReadProperty.

Is it possible to do something like this in C++?

Never having come across the concept before I may be misunderstanding it, but it seems to me you could probably achieve what you want using inheritance (or multiple inheritance).

Something like this, where you just define a getter/setter for a private member?

class MyClass
{
public:
void SetMyMember(const int value) { m_MyMember = value; }
int GetMyMember() { return m_MyMember; }

private:
int m_MyMember;
}

PropertyBag just writes binary to another exe.

Extremely poor response. Tells us absolutamente nada.

You also neglected to tell us which version of VB and which C++ development environment.

From the VB6 help file:

PropertyBag Object

A PropertyBag object holds information that is to be saved and restored across invocations of an object.

Remarks

A PropertyBag object is passed into an object through the ReadProperties event and the WriteProperties event in order to save and restore the state of the object. Using the methods of the PropertyBag object, the object can read or write properties of itself. The ReadProperty method of the PropertyBag object is used to read a value for a property, while the WriteProperty method of the PropertyBag object is used to write a value of a property. The value of a property can itself be an object; in that case the PropertyBag object will attempt to save it.
I assume that this is intended to save the objects' states from one invocation of the program to another. Unfortunately, the help file didn't elaborate on why we would want to use it.

If it's a matter of saving property values -- and assuming that you're still working under Windows -- then it would be like the old .INI files, the profile files, in which you would define a keyword and a value for that keyword and then the next time the program started up it would read that .INI file and use those values to initialize. Profile files have been largely replaced by the Registry. So I would guess that you'd be looking for something like MFC's CWinApp::WriteProfileString or CWinApp::GetProfileString or CWinApp::SetRegistryKey -- if you're not using MFC, then you'd have to search for what your particular development framework has to offer.

Did I guess correctly? If not, then please simplify the process by not forcing us to guess.

Err.

What I want is a way to write some binary data (char) to another exe.

Then when the exe starts, it reads the data.

Err.

What I want is a way to write some binary data (char) to another exe.

Then when the exe starts, it reads the data.

Any number of ways; for example a shared file, command line arguments, or one of a number of forms of inter-process communication (http://msdn2.microsoft.com/en-us/library/aa365574.aspx) .

One thing is for sure no one who has responded so far (including myself) has much of an idea of what a PropertyBag is or does, and your description seems to bear little resemblance to any other, but it seems that it might be amongst the least attractive ways of achieving your aim.

Either way, it is generally better to simply ask directly how to achieve some goal, than to ask how to implement a solution you have already decided upon, without telling us the goal. It gives far more scope for a better answer.

Clifford










privacy (GDPR)